﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="CTitle" ContentPlaceHolderID="TitleContent" runat="server">
	Operator_chat
</asp:Content>
<asp:Content ID="Chead" ContentPlaceHolderID="HeadContent" runat="server">
    <link href="../../Content/ClientChat.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="CBody" ContentPlaceHolderID="MainContent" runat="server">
    <script type="text/javascript">
        $(function () {
            $("#send").click(function () {
                $.post("/Server/SendMessOp/", { mess: $("#mess").val(), id: $("#c_id").val() }, GetCallback, "json");
                $("#mess").val("");
                //alert("get!!");
            });
            GetMess();
            $("#process").css('display', 'none');
            //parent.window.GetCall();
        });
        function FirstMess() {

        }
        function GetMess() {
            setTimeout(GetMess, 3000);
            $.post("/Server/GetMessOp/", { id: $("#c_id").val() }, GetCallback, "json");
            
        }
        function GetCallback(data) {
            //alert(data);
            /*$.each(data, function (i) {
            $("#chat").append("<p>" + this. + "</p>");*/
            $("#chat").append("<p>" + data.message + "</p>");
            //alert(data.message);
            //GetMess();
            //});
        }
        function Disconnect() {
            var c_id = $("#c_id").val();
            $.post("/Server/OperatorDisconnect/", { id: c_id }, GetCallbackDisconnect, "json");            
        }
        function GetCallbackDisconnect(data)
        {
            if (data.dis) {
                window.close();
            }
        }
        $("#body").focus(function () {
            $("#process").css('display', 'inline').fadeOut(3000);
        });
    </script>
    <div id="body">
    <p id="process">Loading...</p>    
    <h2>Оператор</h2>
    <div id="chat">
    </div><br />
    <input type="text" id="mess" /><br />
    <input type="button" id="send" value="Отправить" />
    <input type="button" id="disconnect" value="Выйти" onclick="Disconnect()" />
    <input type="hidden" id="c_id" value="<%=Html.Encode(ViewData["c_id"]) %>" />
    </div>
</asp:Content>


